package com.yoshino.factory.simple_factory.pizzastore.order;

import com.yoshino.factory.simple_factory.pizzastore.pizza.CheesePizza;
import com.yoshino.factory.simple_factory.pizzastore.pizza.GreekPizza;
import com.yoshino.factory.simple_factory.pizzastore.pizza.Pizza;
import lombok.extern.slf4j.Slf4j;

/**
 * @author yoshino
 **/
@Slf4j
public class SimpleFactory {

    public Pizza createPizza(String orderType) {
        Pizza pizza = null;
        log.info("使用简单工厂模式");
        if ("greek".equals(orderType)) {
            pizza = new GreekPizza();
        } else if ("cheese".equals(orderType)) {
            pizza = new CheesePizza();
        }
        return pizza;
    }

    // 简单工厂模式 也叫 静态工厂模式

    public static Pizza createPizza2(String orderType) {
        Pizza pizza = null;
        log.info("使用简单工厂模式");
        if ("greek".equals(orderType)) {
            pizza = new GreekPizza();
        } else if ("cheese".equals(orderType)) {
            pizza = new CheesePizza();
        }
        return pizza;
    }
}
